/*
 * Copyright (C) 2014 luke.
 * 
 * This file is part of Silvie.
 * 
 * Silvie is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Silvie is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Silvie.  If not, see <http://www.gnu.org/licenses/>.
 */

package silvie.resources.video;

import java.io.File;

import silvie.gui.Preview;
import silvie.gui.previewers.AbstractPreviewer;
import silvie.gui.previewers.VideoPreviewer;
import silvie.resources.AbstractResource;
import utils.smacker.SmackerDecoder;
import utils.smacker.SmackerFile;

/**
 * AbstractResource specialization for Smacker videos (SMK files).
 * 
 * @author luke
 */
public class SMKVideo extends AbstractResource {
	private SmackerFile smackerFile;
	private SmackerDecoder smackerDecoder;

	/**
	 * SMKVideo constructor.
	 * 
	 * @param resource the SMK file.
	 */
	public SMKVideo(File resource) {
		super(resource, true);
		this.smackerFile = null;
		this.smackerDecoder = null;
	}

	@Override
	public void extract() throws Exception {
		super.extract();
		this.smackerFile = SmackerFile.openFromStream(super.stream);
		this.smackerDecoder = this.smackerFile.getDecoder();
	}

	@Override
	public AbstractPreviewer getPreviewer(Preview preview) {
		return new VideoPreviewer(preview, this.smackerDecoder, this.smackerFile.getHeader());
	}
}
